import { Component, OnInit, ViewChild } from '@angular/core';
import { STColumn, STComponent } from '@delon/abc/st';
import { SFDateWidgetSchema, SFSchema } from '@delon/form';
import { SearchDrawerService } from '@shared';
import { BasicTableComponent } from 'src/app/routes/commom';
import { WaybillFeeService } from '../../services/waybill-fee.service';

@Component({
  selector: 'app-waybill-management-waybill-fee',
  templateUrl: './waybill-fee.component.html',
  styleUrls: ['../../../commom/less/commom-table.less']
})
export class WaybillManagementWaybillFeeComponent extends BasicTableComponent implements OnInit {
  url = `/user`;
  schema!: SFSchema;
  columns: STColumn[] = [];

  constructor(public searchDrawerService: SearchDrawerService, public service: WaybillFeeService) {
    super(searchDrawerService);
  }
  /**
   * 查询参数
   */
  get reqParams() {
    const a: any = {};
    const params: any = { ...this.sf?.value };
    delete params._$expand;
    return {
      ...params
    };
  }

  ngOnInit(): void {
    this.initSF();
    this.initST();
  }
  /**
   * 初始化查询表单
   */
  initSF() {
    this.schema = {
      properties: {
        billCode: {
          type: 'string',
          title: '订单号',
          ui: {
            placeholder: '请输入'
          }
        },
        wayBillCode: {
          type: 'string',
          title: '运单号',
          ui: {
            placeholder: '请输入'
          }
        },
        wbCreateTime: {
          title: '运单生成起止时间',
          type: 'string',
          ui: {
            widget: 'date',
            mode: 'range',
            format: 'yyyy-MM-dd',
            allowClear: true
          } as SFDateWidgetSchema
        },
        dispatchedDate: {
          title: '发货起止时间',
          type: 'string',
          ui: {
            widget: 'date',
            mode: 'range',
            format: 'yyyy-MM-dd',
            allowClear: true
          } as SFDateWidgetSchema
        },
        receivingDate: {
          title: '收货起止时间',
          type: 'string',
          ui: {
            widget: 'date',
            mode: 'range',
            format: 'yyyy-MM-dd',
            allowClear: true
          } as SFDateWidgetSchema
        }
      }
    };
  }

  /**
   * 初始化数据列表
   */
  initST() {
    this.columns = [
      { title: '序号', type: 'no', width: '70px', className: 'text-center' },
      {
        title: '订单号',
        width: '180px',
        className: 'text-center',
        render: 'billCode'
      },
      {
        title: '运单号',
        width: '180px',
        fixed: 'left',
        className: ' text-center',
        render: 'wayBillCode'
      },

      {
        title: '运单生成时间',
        width: '180px',
        className: 'text-center',
        index: 'orderReceivingTime'
      },
      {
        title: '发货时间',
        width: '180px',
        className: 'text-center',
        index: 'loadTime'
      },
      { title: '收货时间', index: 'unloadTime', width: '180px', className: 'text-center' },
      {
        title: '订单金额',
        index: 'billAmount',
        width: '150px',
        className: 'text-right',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.billAmount }) }
      },
      {
        title: '货主已支付金额',
        index: 'shipperPayAmount',
        width: '180px',
        className: 'text-right',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.shipperPayAmount }) }
      },
      {
        title: '货主未支付金额',
        index: 'shipperNotPayAmount',
        width: '180px',
        className: 'text-right',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.shipperNotPayAmount }) }
      },
      {
        title: '已开票金额',
        index: 'ticketAmount',
        width: '150px',
        className: 'text-right',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.ticketAmount }) }
      },
      {
        title: '未开票金额',
        index: 'notTicketAmount',
        width: '150px',
        className: 'text-right',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.notTicketAmount }) }
      },
      {
        title: '运费金额',
        className: 'text-right',
        width: '150px',
        index: 'wbAmount',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.wbAmount }) }
      },
      {
        title: '司机已收款金额',
        className: 'text-right',
        width: '150px',
        index: 'driverGetAmount',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.driverGetAmount }) }
      },
      {
        title: '司机未收款金额',
        className: 'text-right',
        width: '150px',
        index: 'driverNotGetAmount',
        type: 'widget',
        widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.driverNotGetAmount }) }
      }
    ];
  }
  search() {
    this.st?.load(1);
  }
  exprot() {}
}
